n = int(input())
if len(str(n)) != 4:
    n = int(input())
for j in range(n):
    p = j
h = 9
for i in range(h):
    if j/h != 1 and j//1:
        p = max(j)
print(p)
